// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#include <pollux/functions/lib/registration_helpers.h>
#include <pollux/functions/prestosql/binary_functions.h>
#include <pollux/functions/sparksql/hash.h>
#include <pollux/functions/sparksql/might_contain.h>
#include <pollux/functions/sparksql/string.h>

namespace kumo::pollux::functions::sparksql {
    void registerBinaryFunctions(const std::string &prefix) {
        register_function<CRC32Function, int64_t, Varbinary>({prefix + "crc32"});
        exec::registerStatefulVectorFunction(
            prefix + "hash", hashSignatures(), makeHash, hashMetadata());
        exec::registerStatefulVectorFunction(
            prefix + "hash_with_seed",
            hashWithSeedSignatures(),
            makeHashWithSeed,
            hashMetadata());
        exec::registerStatefulVectorFunction(
            prefix + "xxhash64", xxhash64Signatures(), makeXxHash64, hashMetadata());
        exec::registerStatefulVectorFunction(
            prefix + "xxhash64_with_seed",
            xxhash64WithSeedSignatures(),
            makeXxHash64WithSeed,
            hashMetadata());
        register_function<Md5Function, Varchar, Varbinary>({prefix + "md5"});
        register_function<BloomFilterMightContainFunction, bool, Varbinary, int64_t>(
            {prefix + "might_contain"});
        register_function<Sha1HexStringFunction, Varchar, Varbinary>(
            {prefix + "sha1"});
        register_function<Sha2HexStringFunction, Varchar, Varbinary, int32_t>(
            {prefix + "sha2"});
    }
} // namespace kumo::pollux::functions::sparksql
